<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	
<%@ page import="java.sql.CallableStatement"%>
<%@ page import="java.sql.Connection"%>
<%@ page import="java.sql.DriverManager"%>
<%@ page import="java.sql.PreparedStatement"%>
<%@ page import="java.sql.ResultSet"%>
<%@ page import="java.sql.SQLException"%>
<%@ page import="java.sql.Statement"%>
<%@ page import="oracle.jdbc.OracleTypes"%>
<%@ page import="oracle.jdbc.internal.OracleCallableStatement"%>
<%@ page import="oracle.jdbc.oracore.OracleType"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<%
		String driver = "oracle.jdbc.driver.OracleDriver";
		String url = "jdbc:oracle:thin:@localhost:1521:orcl";
		String user = "scott";
		String password = "tiger";

		Connection conn = null;
		CallableStatement cstmt = null;
		OracleCallableStatement ocstmt = null;
		ResultSet rs = null;

		try {
			Class.forName(driver);
			conn = DriverManager.getConnection(url, user, password);

			cstmt = conn.prepareCall("{call test_ref_cursor(?,?)}"); //�꾨줈�쒖� �대쫫 �몄텧!!!
			cstmt.registerOutParameter(1, OracleTypes.CURSOR); //sysrefcsr  泥ル쾲吏�蹂�닔
			cstmt.setInt(2, 10); //遺�꽌

			if (!cstmt.execute()) {
				ocstmt = (OracleCallableStatement) cstmt;
				rs = ocstmt.getCursor(1);
				out.println("<table border='1'>");
				while (rs.next()) {
					out.println("<tr>");
					String empno=rs.getString(1);
					String ename=rs.getString(2);
					String sal=rs.getString(3);
					System.out.println(empno + "  "+ ename + "   " + sal);
					
					out.println("<td>" + empno + "</td>");
					out.println("<td>" + ename + "</td>");
					out.println("<td>" + sal + "</td>");
					out.println("</tr>");
				}
				out.println("</table>");
			}
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			if (rs != null)	try {rs.close();}catch (SQLException e) {}
			if (ocstmt != null)	try {	ocstmt.close();	} catch (SQLException e) {	}
			if (cstmt != null)try {cstmt.close();} catch (SQLException e) {	}
			if (conn != null)try {	conn.close();} catch (SQLException e) {	}
		}
	%>
</body>
</html>